//
//  ImageTableViewCell.swift
//  StealPicture
//
//  Created by 郭斌勇 on 16/8/19.
//  Copyright © 2016年 ?! 郭斌勇. All rights reserved.
//

import UIKit

class ImageTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDataSource {

    var 内容类别:内容类别_CL?{
        
        didSet{
            刷新视图()
        }
        
    }

    @IBOutlet weak var imageCollectionView: UICollectionView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        
        // Configure the view for the selected state
    }
    
    
    
    
    
    //MARK:UICollectionView 的代理方法
    
    
    
    
    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
        
        return (内容类别?.成员集合.count)!
    }
    
    
    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{
        
        let collectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("ImageCollectionViewCell", forIndexPath: indexPath) as! ImageCollectionViewCell
        
        let 图片信息 = 内容类别?.成员集合[indexPath.item]
        collectionViewCell.显示原图 = true
        collectionViewCell.图片信息 = 图片信息
        return collectionViewCell
        
    }
    
    
    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize{
        
        
        let cellHeight = imageCollectionView.frame.height
        return CGSize(width:cellHeight, height: cellHeight)
    }
    
    
    
    func 刷新视图(){
        
        dispatch_async(dispatch_get_main_queue(), {
            
            self.imageCollectionView.reloadData()
            self.imageCollectionView.reloadData()
        })
    }
    
    
//    
//    func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
//        
//        
//        
//    }
    
    

}
